package com.imessage.type;

import com.fasterxml.jackson.annotation.JsonValue;
import io.ebean.annotation.DbEnumValue;

import java.util.Objects;

public enum BaseConfigCode implements EnumMessage {

	file_server_user("1", "文件服务器账号","file_server_user","http://127.0.0.1:9001"),
	file_server_passwd("2", "文件服务器密码","file_server_passwd","http://127.0.0.1:9001"),
	apple_send_num("3", "苹果账号可发送数量","apple_send_num","80"),
	virtual_max_exist_num("4", "虚拟机最大存在数量","virtual_max_exist_num","500"),
	virtual_max_run_num("5", "虚拟机最大运行数量","virtual_max_run_num","5"),
	max_silence_time("6", "虚拟机最大静默时间","max_silence_time","60"),
	scp_user("7", "scp用户名","scp_user","scp_user"),
	scp_passwd("8", "scp密码","scp_passwd","scp_passwd"),
	other("99", "其他","other","");

	
	String code;
	String display;
	String name;
	String value;

	private BaseConfigCode(String code, String display, String name, String value) {
		this.code = code;
		this.display = display;
		this.name=name;
		this.value=value;
	}

	//获取枚举实例
	public static BaseConfigCode fromValue(String code) {
		for (BaseConfigCode statusEnum : BaseConfigCode.values()) {
			if (Objects.equals(code, statusEnum.getCode())) {
				return statusEnum;
			}
		}
		return BaseConfigCode.other;
	}

	//获取枚举实例
	public static BaseConfigCode toValue(String display) {
		for (BaseConfigCode statusEnum : BaseConfigCode.values()) {
			if (Objects.equals(display, statusEnum.getDisplay())) {
				return statusEnum;
			}
		}
		return BaseConfigCode.other;
	}

	@DbEnumValue
	@Override
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Override
	@JsonValue
	public String getDisplay() {
		return display;
	}

	public void setDisplay(String display) {
		this.display = display;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}


	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}
	
	@Override
	public String toString() {		
		return display;
	}


}
